//
//  CustUIToolBar.m
//  iTinyBag
//
//  Created by maxh on 1/2/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "CustUIToolBar.h"


@implementation CustUIToolBar
@synthesize delegate;

-(void)ViewBKContacts:(UIBarButtonItem *)sender{
	if ( [delegate respondsToSelector:@selector(ViewBackupContacts:)] )
	{		
		[delegate ViewBackupContacts:sender];		
	}
}

-(void)BackupItem:(UIBarButtonItem *)sender
{
	if ( [delegate respondsToSelector:@selector(Backup:)] )
	{		
		[delegate Backup:sender];		
	}
}
- (void)ShareItem:(UIBarButtonItem *)sender
{
	if ( [delegate respondsToSelector:@selector(Share:)] )
	{		
		[delegate Share:sender];		
	}
}
- (void)ViewItem:(UIBarButtonItem *)sender
{
	if ( [delegate respondsToSelector:@selector(View:)] )
	{		
		[delegate View:sender];		
	}
}

-(id)Delegate
{
	return delegate;
}

-(void)setDelegate:(id) cutbDelegate
{
	delegate=cutbDelegate;
}

-(void)loadItems
{
	NSMutableArray *toolBarItems=[[[NSMutableArray alloc] init] autorelease];
	
	
	 [toolBarItems addObject:[[[UIBarButtonItem alloc] initWithTitle:@"View Back-Up Contacts" style:UIBarButtonItemStyleBordered target:self action:@selector(ViewBKContacts:)] autorelease]];
	 /*
	[toolBarItems addObject:[[[UIBarButtonItem alloc] initWithTitle:@"Cover Local Contact" style:UIBarButtonItemStyleBordered target:self action:@selector(BackupItem:)] autorelease]];

	[toolBarItems addObject:[[[UIBarButtonItem alloc] initWithTitle:@"Synchronise Backup" style:UIBarButtonItemStyleBordered target:self action:@selector(BackupItem:)] autorelease]];
	
	[toolBarItems addObject:[[[UIBarButtonItem alloc] initWithTitle:@"Restore" style:UIBarButtonItemStyleBordered target:self action:@selector(BackupItem:)] autorelease]];
	
	
	[toolBarItems addObject:[[[UIBarButtonItem alloc] initWithTitle:@"Backup" style:UIBarButtonItemStyleBordered target:self action:@selector(BackupItem:)] autorelease]];
	
	[toolBarItems addObject:[[[UIBarButtonItem alloc] initWithTitle:@"Share" style:UIBarButtonItemStyleBordered target:self action:@selector(ShareItem:)] autorelease]];
	*/
	
	[toolBarItems addObject:[[[UIBarButtonItem alloc] initWithTitle:@"View" style:UIBarButtonItemStyleBordered target:self action:@selector(ViewItem:)] autorelease]];
	
	[self setItems:toolBarItems];
}

- (id)initWithFrame:(CGRect)aRect
{
	if([super initWithFrame:aRect]==self)
	{		
		[self loadItems];
	}
	
	return self;
}

- (id)init
{
	if([super init]==self)
	{		
		[self loadItems];
	}
	
	return self;
}

@end
